package com.rc.saas.tenant.controller.invite;

import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.base.WebPageInfo;
import com.rc.saas.tenant.search.invite.InviteSearch;
import com.rc.saas.tenant.service.invite.MemberInviteLinkService;
import com.rc.saas.tenant.service.invite.MemberInviteSettingService;
import com.rc.saas.tenant.vo.invite.InviteMemberDetailVo;
import com.rc.saas.tenant.vo.invite.InviteSettingVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/inviteGain")
public class InviteGainController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    private final String sessionInvitePrefix = "inviteGain";

    @Autowired
    private MemberInviteSettingService memberInviteSettingService;

    @Autowired
    private MemberInviteLinkService memberInviteLinkService;

    /**
     * 跳转邀请有奖页面
     * 奖励类型 1赠送优惠券  2返利
     * @param
     * @return
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(Model model) {
        return "/templates/invite/inviteGainList";
    }

    /**
     * 返利列表数据统计
     * @return
     */
    @RequestMapping(value = "/listInviteGain", method = RequestMethod.GET)
    @ResponseBody
    public WebPageInfo listPageInviteGain(InviteSearch inviteSearch) {
        PageInfo<InviteSettingVo> pageInfo = memberInviteSettingService.listPageInviteGain(inviteSearch);
        WebPageInfo webPageInfo = new WebPageInfo(pageInfo.getList(), Long.valueOf(pageInfo.getTotal()).intValue());
        return webPageInfo;
    }



    /**
     * 邀请新用户的明细列表
     * @return
     */
    @RequestMapping(value = "/listInviteLinkDetail", method = RequestMethod.GET)
    @ResponseBody
    public WebPageInfo listInviteLinkDetail(InviteSearch inviteSearch) {
        PageInfo<InviteMemberDetailVo> pageInfo = memberInviteLinkService.listInviteLinkDetail(inviteSearch);
        WebPageInfo webPageInfo = new WebPageInfo(pageInfo.getList(), Long.valueOf(pageInfo.getTotal()).intValue());
        return webPageInfo;
    }

}
